package com.security;

import com.config.ContextUtils;

import java.util.Map;
import java.util.Objects;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/5/12 9:59
 * @since JDK 1.8
 */
public class HttpMap {


    /**
     * 获取value
     * @param key
     * @return
     */
    public Object getObjectByKey(String key){
        Map<String, Object> objectMap=getMap();
        if(objectMap.containsKey(key)){
            return objectMap.get(key);
        }else {
            return null;
        }
    }

    /**
     * 通过key删除value
     * @param key
     * @return
     */
    public boolean removeObjectByKey(String key){
        Map<String, Object> objectMap=getMap();
        if(objectMap.containsKey(key)){
          objectMap.remove(key);
          return true;
        }
        return false;
    }

    public boolean addObject(String key, Object value){
        Map<String, Object> objectMap=getMap();
        objectMap.put(key,value);
        return true;
    }


    private static Map<String, Object> getMap(){
      return ContextUtils.getBeanObj("securityobj");
    }
}
